package org.example.model;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;
import java.util.Date;

@Data
//隐藏数据为空的数据
@JsonInclude(value = JsonInclude.Include.NON_NULL)
public class User implements Serializable {
    private Integer id;
    private String username;
    private String password;
    private Integer age;
    private String remark;
    private Integer sex;
    private String avatar;

//    时间格式化
//@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createtime;

    public User(){}
    public User(Integer id){ this.id = id; }

    //public String getPerms(){ return }
    public Integer getId(){ return id; }
    public void setId(Integer id){ this.id = id; };

    public String getUsername(){ return username; }
    public void setUsername(String username){ this.username = username; };

    public Integer getAge(){ return age; }
    public void setAge(Integer age){ this.age = age; };

    public String getRemark(){ return remark; }
    public void setRemark(String remark){ this.remark = remark; };

    public Integer getSex(){ return sex; }
    public void setSex(Integer sex){ this.sex = sex; };

    public String getAvatar(){ return avatar; }
    public void setAvatar(String avatar){ this.avatar = avatar; };

    public Date getCreatetime(){ return createtime; }
    public void setCreatetime(Date createtime){ this.createtime = createtime; };



    @Override
    public String toString(){
        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
                .append("id",getId())
                .append("username",getUsername())
                .append("age",getAge())
                .append("remark",getRemark())
                .append("sex",getSex())
                .append("avatar",getAvatar())
                .append("createtime",getCreatetime())
                .toString();
    }

}
